import { keys } from 'lodash-es';
import * as CarbonIcons from '@vicons/carbon';

const SvgIcons = import.meta.glob('../assets/svg/**/*.svg');

export const carbonIconComponents = keys(CarbonIcons).map((key: string) => {
  const component = Reflect.get(CarbonIcons, key) as Component;

  return {
    name: `Carbon${component.name ?? key}`,
    component,
  };
});

export const svgIconComponents = keys(SvgIcons).map((key: string) => {
  const component = Reflect.get(SvgIcons, key) as Component;
  const name = key.split('/assets/svg/')[1].split('.')[0];

  return {
    name,
    component,
  };
});
